package com.xq.service.tesk;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xq.base.ResponseResult;
import com.xq.service.IdentityService;

import java.util.concurrent.Callable;

public class LiveAuthTask implements Callable<Boolean> {

    private String base64LiveImage;
    private IdentityService identityService;

    public LiveAuthTask(String base64LiveImage, IdentityService identityService){
        this.base64LiveImage=base64LiveImage;
        this.identityService=identityService;
    }

    @Override
    public Boolean call() throws Exception {
        Boolean flag = false;
        //调用活体接口
        String str = identityService.liveAuth(base64LiveImage);
        System.out.println("活体对比结果::"+str);
        JSONObject json = JSON.parseObject(str);
        Integer code = json.getInteger("code");
        //0代表成功
        if(code==0){
            JSONObject data = json.getJSONObject("data");
            Integer score = data.getInteger("score");
            if(score>75){
                flag=true;
            }
        }
        return flag;
    }
}
